package cn.exrick.xboot.modules.Information.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.text.NumberFormat;

@Data
@ApiModel(value = "各段所运行情况表")
public class ParagraghOperation {

    @ApiModelProperty(value = "镇名称")
    private String title;

    @ApiModelProperty(value = "未完成事件数")
    private Integer pendingTrial;

    @ApiModelProperty(value = "结束事件数")
    private Integer accomplish;

    @ApiModelProperty(value = "审核率")
    private String percentage;

    @ApiModelProperty(value = "第三方上报问题数")
    private Integer thirdParty;

    @ApiModelProperty(value = "巡管员上报问题数")
    private Integer riverPatrol;

    public String getPercentage(){
        String format ="";
        if (accomplish != 0){
            float f = (float)accomplish/(float) (pendingTrial + accomplish);
            NumberFormat nt = NumberFormat.getPercentInstance();//获取格式化对象
            nt.setMinimumFractionDigits(2);//设置百分数精确度2即保留两位小数
            format = nt.format(f);//最后格式化并输出
        }else {
            format = "0%";
        }
        return format;
    }
}
